import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop034-客户管理管理客户余额调整流程"

str1="cyy"
num1=10000
str2="买手机用"

# 1.点击“余额调整”按钮。
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"客户管理","管理客户")
# 2.添加客户cyy,金额增加"10000",备注内容“买手机用”
str3=firefox.find_element_by_xpath("//td[text()='%s']/following-sibling::td[5]"%str1).text
firefox.find_element_by_xpath("//td[text()='%s']/following-sibling::td[7]/a[2]"%str1).click()
time.sleep(2)
firefox.find_element_by_id("money_change_num").send_keys(num1)
firefox.find_element_by_id("money_pay_info").send_keys(str2)
# 3.点击“提交充值”按钮。在前台查询cyy是否余额多10000.
firefox.find_element_by_xpath("//button[text()='提交充值']").click()
time.sleep(2)
# 断言
str4=firefox.find_element_by_xpath("//td[text()='%s']/following-sibling::td[5]"%str1).text
if float(str4)==float(str3)+num1:
    writeLog("%s 测试通过" % testCase)
else:
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
firefox.quit()
